const express = require('express');
const app = express();
const history = require('connect-history-api-fallback');
const path = require('path');
const router = express.Router();

// app.use(router);



// app.use('/helloWorld', history());
// app.use('/', history());
app.use('/', history({
    rewrites: [
        {
            from: /^\/.*$/,
            to(context) {
                return "/";
            }
        }
    ]
}));
app.get('/', function (req, res) {
    res.sendFile(path.join(__dirname, "project/saas/index.html"));
});
app.use(express.static('./project'));
// app.use(express.static('./production'));


// router.get('/', (req, res, next) => {
//     // req.url = '/index.html';
//     res.sendFile(path.join(__dirname, "./project/saas/index.html"));
//     next();
// });
const open = require('opn');

// 启动成功打开网页
const port = 3550; // 端口号
module.exports = app.listen(port, (err) => {
    if (err) {
        console.log(err);
        return;
    }
    open(`http://localhost:${port}`);
    console.log(`Listening at http://localhost:${port}\n`);
});
